<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>Document</title>
  <style>
     td{
	   border:solid 1px black; 
	   height:30px;
	   width:100px;
	   text-align:center;
	 }
  </style>
 </head>
 <body>
    <div>
	  <table id="table">
	    <tr> <td>标题_1</td> <td>标题_2</td> <td>标题_3</td> <td>标题_4</td> </tr>
		<tr> <td></td> <td></td> <td></td> <td></td> </tr>
	  </table>
	  <button id="btn_1">增加一行</button> <button id="btn_2">删除最后一行</button>
	<div>
 </body>
 <script>
    var n = 0;
    var btn_create = document.getElementById("btn_1");
	var btn_delete = document.getElementById("btn_2");
   
	btn_create.onclick = function(){
	 var table = document.getElementById("table");
	 var tr_create = document.createElement("tr");
	 for(var i = 0;i < 4;i++){
	   var td_create = document.createElement("td");
	   td_create.style.height = "30px";
	   td_create.style.width = "100px";
	   td_create.style.border = "solid 1px black";
	   tr_create.appendChild(td_create);
	 }
	table.appendChild(tr_create);
	n++;
	}

	btn_delete.onclick = function(){
	  if(n > 0){
	   var table = document.getElementById("table");
	   var td = table.lastChild;
       table.removeChild(td);
	   n--;
	  }
	}
 </script>
</html>
